package com.android.jianboshi.dialog;

import android.os.Handler;
import android.widget.TextView;

import androidx.fragment.app.FragmentActivity;

import com.android.baselibrary.dialog.BaseDialogFragment;
import com.android.baselibrary.interface_.CommCallBack;
import com.android.baselibrary.tool.Log;
import com.android.baselibrary.util.AnimUtil;
import com.android.jianboshi.R;
import com.android.jianboshi.manager.MedioPlayerUtil;

import java.util.Map;

import butterknife.BindView;

/**
 * 倒计时
 */

public class DaoJiShi_DialogFragment extends BaseDialogFragment {

    @BindView(R.id.tv_num)
    TextView tv_num;

    int num = 3;
    MedioPlayerUtil playerUtil;

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_daojishi;
    }

    @Override
    protected void initData() {
        playerUtil = new MedioPlayerUtil(mContext, null);

        playerUtil.setData("music/daojishi1.mp3",false);
        scale();
    }

    @Override
    protected void initView() {
    }

    @Override
    protected boolean setCanceledOnTouchBACK() {
        return false;
    }

    @Override
    protected int getShowDirection() {
        return BaseDialogFragment.Direction_FadeIn;
    }

    @Override
    public void setData(Map<String, Object> params) {
        if (params != null) {

        }
    }

    private void scale() {
        Log.i("num:"+ num);
        if (num > 0) {
            tv_num.setText(num+ "");
            AnimUtil.scaleBig(tv_num, 1000, new CommCallBack() {
                @Override
                public void onResult(Object obj) {
                    num--;
                    scale();
                }
            });
        }
        else
        {
            if(callBack!=null)
            {
                callBack.onResult(null);
            }
            dismissWithAnim();
        }
    }

    public static BaseDialogFragment showDialog(FragmentActivity activity, Map<String, Object> params) {
        DaoJiShi_DialogFragment dialogFragment = new DaoJiShi_DialogFragment();
        dialogFragment.setData(params);
        dialogFragment.show(activity.getSupportFragmentManager(), "");
        return dialogFragment;
    }


//    @OnClick({R.id.ll_share_wx })
//    public void onViewClicked(View view) {
//        switch (view.getId()) {
//            case R.id.ll_share_wx:          //分享-微信
//
//                break;
//        }
//    }


}
